package com.gitee.apecome.core.remote.net.netty.client.handler;

import com.gitee.apecome.core.remote.ApeRpcFactory;
import com.gitee.apecome.core.remote.bean.ApeRpcResponse;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class NettyClientHandler extends SimpleChannelInboundHandler<ApeRpcResponse> {

    private ApeRpcFactory factory;

    public NettyClientHandler(ApeRpcFactory factory) {
        this.factory = factory;
    }

    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, ApeRpcResponse apeRpcResponse) throws Exception {
        System.out.println("接收结果 from server ");
        factory.setResponse(apeRpcResponse);
    }
}
